/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package actions;

import com.paris5.master2.guitarmaster.bean.EcomBid;
import com.paris5.master2.guitarmaster.bean.EcomComment;
import com.paris5.master2.guitarmaster.bean.EcomProduct;
import com.paris5.master2.guitarmaster.bean.EcomProductType;
import com.paris5.master2.guitarmaster.exception.EcomQueryException;
import com.paris5.master2.guitarmaster.service.ServiceProductRemote;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

/**
 *
 * @author Alice
 */
public class FicheProduitEnchere extends EcomAction implements ServletRequestAware{
    private EcomProduct product;
    private int idProduct;
    private EcomBid bid;
    HttpServletRequest request;

    public void setIdProduct(int idProduct) {
        this.idProduct = idProduct;
    }

    public int getIdProduct() {
        return idProduct;
    }

    public EcomProduct getProduct() {
        return product;
    }

    public void setProduct(EcomProduct product) {
        this.product = product;
    }

    
    @Override
    public void setServletRequest(HttpServletRequest request) {
	this.request=request;
    }

    public EcomBid getBid() {
        return bid;
    }

    public void setBid(EcomBid bid) {
        this.bid = bid;
    }

 
    @Override
    public String execute(){
        try {
            ServiceProductRemote serviceProductRemote = lookupServiceProductRemote();
            idProduct = (int) Double.parseDouble(request.getParameter("idProduct"));
            product = serviceProductRemote.getProduct(idProduct);
            bid = serviceProductRemote.getLastProductPriceInBid(product, 1, true);
            return SUCCESS;
        } catch (EcomQueryException ex) {
            Logger.getLogger(FicheProduit.class.getName()).log(Level.SEVERE, null, ex);
        }
        return ERROR;
    }
    
}
